﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace TaiwuModFramework.Common.Abstract {

    /// <summary>
    /// 配置项读取工具抽象类
    /// </summary>
    public abstract class AConfigItemReader {

        public abstract Type ItemType();
        public abstract object Read(string modIdStr ,string itemName);

        public T Read<T>(string modIdStr ,string itemName) {
            var type = ItemType();
            if(type == null) throw new Exception("未配置配置项类型");
            if(!type.Equals(typeof(T))) throw new Exception("配置类型与传入的泛型类型不一致");
            return (T)Read(modIdStr,itemName);
        }
    }
}
